package com.freewater.springboot.demo.resource.messagesource;

import com.freewater.springboot.demo.PackageUtils;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;

@Configuration
public class AppConfig {

    @Bean
    public MessageSource messageSource() {
        final ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        messageSource.setCacheSeconds(2);
        messageSource.setBasenames(PackageUtils.getClassPathFroClass(AppConfig.class) + "/exception");
        return messageSource;
    }

    @Bean
    public SomeService someService() {
        return new SomeService();
    }
}
